<template>
	<uni-collapse :accordion="true">
		<uni-collapse-item v-for="(item,index) in answerList" :key="index" :title="item.questionstitle" :desc="item.answertime"
		 :show-animation="true">
			<!-- <view>
				<span class="content">试题内容:</span>
				<rich-text class="miningpoint" :nodes="item.questionsname"></rich-text>
			</view>
			<view>
				<span class="content">采分点:</span>
				<rich-text class="miningpoint" :nodes="item.miningpoint "></rich-text>
			</view>
			<view>
				<span class="content">标准答案:</span>
				<rich-text :nodes="item.answer"></rich-text>
			</view> -->
			<view>
				<span class="content">【我的答案】</span>
				<rich-text :nodes="item.myanswer"></rich-text>
			</view>
			<block v-if="item.source == '1'">
				<view>
					<span class="content">【评语】</span>
					<rich-text :nodes="item.comment"></rich-text>
				</view>
				<view>
				
					<span class="content">【得分】</span>
					<view class="score">{{ item.score }}</view>
				</view>
				<view>
				
					<span class="content">【批改人】</span>
					<view class="comrname">{{ item.comrname }}</view>
				</view>
			</block>
			
			<block v-if="item.source == '2' || item.source == '3'">
				
				<view>
					<span class="content">【评语】</span>
					<rich-text :nodes="item.correctcomment"></rich-text>
				</view>
				<view>
					<span class="content">【批改语音】</span>
					<view class="imt-audio" v-if="item.correctorvo!=''">
						<view class="audio-control-wrapper" >
							<view class="audio-control audio-control-switch" :class="{audioLoading:loading}"  @click="operation">
								<image v-if="paused" src="/static/img/audio/play.png" class="audio-img" mode=""></image>
								<image v-if="!paused" src="/static/img/audio/pause.png" class="audio-img" mode=""></image>
							</view>
						</view>
					</view>
				</view>
				
				<view>
					<view class="score">{{ item.correctscore }}</view>
				</view>
				<view>
					<span class="content">【批改时间】</span>
					<view class="score">{{ item.correcttime }}</view>
				</view>
				<view>
					<span class="content">【批改人】</span>
					<view class="comrname">{{ item.corrector }}</view>
				</view>
			</block>
			
		</uni-collapse-item>

	</uni-collapse>
</template>
<script>
	import uniCollapse from '@/components/uni-collapse/uni-collapse.vue'
	import uniCollapseItem from '@/components/uni-collapse-item/uni-collapse-item.vue'
	import uniList from '@/components/uni-list/uni-list.vue'
	import uniListItem from '@/components/uni-list-item/uni-list-item.vue'

	import discussMarkApi from "@/api/discussMark.js"

	let _this
	export default {
		components: {
			uniCollapse,
			uniCollapseItem,
			uniList,
			uniListItem
		},
		onLoad(query) {
			_this = this;
			_this.query = query;
			_this.initData()
		},
		data() {
			return {
				answerList: [],
				page: 1,
				pagenum: 20,
				count: 0,
				query: {},
				
				loading: false, //是否处于读取状态
				paused: true, //是否处于暂停状态
				seek: false //是否处于拖动状态
			};
		},

		computed: {

		},
		onReachBottom(e) {
			console.log(e)
			if (_this.count == _this.st.length) {
				return
			}
			_this.page = _this.page + 1
			_this.initData()
		},
		methods: {
			initData() {
				let {
					usercode
				} = uni.getStorageSync('user')
				let {
					teacode
				} = _this.query
				let data = {
					usercode: usercode,
					teacode: teacode,
					page: _this.page,
					pagenum: _this.pagenum,
					type:2
				}
				discussMarkApi.brst(data).then(res => {
					console.log(res)
					_this.count = res.data.count
					res.data.list = res.data.list || []
					_this.answerList = _this.answerList.concat(res.data.list)
				}).catch(err => {
					console.log(err)
				})
			},
			
			//播放/暂停操作
			operation() {
				if (_this.paused) {
					audio.play()
					this.loading = true
				} else {
					audio.pause()
				}
			},
			initAudio(){
				let audio = uni.createInnerAudioContext(); //创建音频
				audio.src = _this.item.correctorvo
				audio.obeyMuteSwitch = false
				audio.autoplay = false
				//音频播放事件
				audio.onPlay(() => {
					_this.paused = false
					_this.loading = false
				})
				//音频暂停事件
				audio.onPause(() => {
					_this.paused = true
				})
				//音频结束事件
				audio.onEnded(() => {
					if (_this.continue) {
						_this.next()
					} else {
						_this.paused = true
						_this.current = 0
					}
				})
				//音频完成更改进度事件
				audio.onSeeked(() => {
					_this.seek = false
				})
			}

		},

		onReady() {}
	};
</script>
<style lang="scss">
	.content {
		
		display: flex;
		justify-content: flex-start;
		align-items: center;
		// width: 100%;
		padding: 0 30upx;
		line-height: 50upx;
		font-size: $font-sm+5;
		color: #4f81bd;
		word-wrap: break-all;
		flex-wrap: wrap;
		font-weight: 600;

		>view {
			width: 100%;
			margin-left: 10upx;
			word-wrap: break-word;
			font-weight: 500;
		}

		.score {
			font-size: $font-sm + 2upx;
			line-height: 40upx;
			color: $uni-color-primary;
			word-wrap: normal;
			overflow: hidden;
		}

		.comrname {
			word-wrap: normal;
			overflow: hidden;
		}

	}
	.audio-control-wrapper {
		margin-top: 10upx;
		display: flex;
		justify-content: center;
		align-items: center;
		// color:#169af3;
	}
	.audio-control {
		font-size: 32upx;
		line-height: 1;
		// border: 4upx solid;
		// border-radius: 50%;
		padding: 16upx;
		.audio-img{
			width: 100upx;
			height: 100upx;
		}
	}
</style>
